
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.io.qchem.outputs &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
    <script src="../../../../_static/jquery.js"></script>
    <script src="../../../../_static/underscore.js"></script>
    <script src="../../../../_static/doctools.js"></script>
    <script src="../../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.qchem.outputs</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.io.qchem.outputs</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Parsers for Qchem output files.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">List</span>
<span class="kn">import</span> <span class="nn">math</span>
<span class="kn">import</span> <span class="nn">copy</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

<span class="kn">from</span> <span class="nn">monty.io</span> <span class="kn">import</span> <span class="n">zopen</span>
<span class="kn">from</span> <span class="nn">monty.json</span> <span class="kn">import</span> <span class="n">jsanitize</span>
<span class="kn">from</span> <span class="nn">monty.json</span> <span class="kn">import</span> <span class="n">MSONable</span>
<span class="kn">from</span> <span class="nn">pymatgen.core</span> <span class="kn">import</span> <span class="n">Molecule</span>

<span class="kn">from</span> <span class="nn">pymatgen.analysis.graphs</span> <span class="kn">import</span> <span class="n">MoleculeGraph</span>
<span class="kn">from</span> <span class="nn">pymatgen.analysis.local_env</span> <span class="kn">import</span> <span class="n">OpenBabelNN</span>
<span class="kn">import</span> <span class="nn">networkx</span> <span class="k">as</span> <span class="nn">nx</span>

<span class="k">try</span><span class="p">:</span>
    <span class="kn">from</span> <span class="nn">openbabel</span> <span class="kn">import</span> <span class="n">openbabel</span> <span class="k">as</span> <span class="n">ob</span>

    <span class="n">have_babel</span> <span class="o">=</span> <span class="kc">True</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="n">ob</span> <span class="o">=</span> <span class="kc">None</span>
    <span class="n">have_babel</span> <span class="o">=</span> <span class="kc">False</span>

<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">read_table_pattern</span><span class="p">,</span> <span class="n">read_pattern</span><span class="p">,</span> <span class="n">process_parsed_coords</span>

<span class="n">__author__</span> <span class="o">=</span> <span class="s2">&quot;Samuel Blau, Brandon Wood, Shyam Dwaraknath&quot;</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s2">&quot;Copyright 2018, The Materials Project&quot;</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;0.1&quot;</span>

<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>


<div class="viewcode-block" id="QCOutput"><a class="viewcode-back" href="../../../../pymatgen.io.qchem.outputs.html#pymatgen.io.qchem.outputs.QCOutput">[docs]</a><span class="k">class</span> <span class="nc">QCOutput</span><span class="p">(</span><span class="n">MSONable</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class to parse QChem output files.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            filename (str): Filename to parse</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filename</span> <span class="o">=</span> <span class="n">filename</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>

        <span class="c1"># Check if output file contains multiple output files. If so, print an error message and exit</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;multiple_outputs&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Job\s+\d+\s+of\s+(\d+)\s+&quot;</span>
            <span class="p">},</span>
            <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;multiple_outputs&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">None</span>
                <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;multiple_outputs&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[</span><span class="s1">&#39;1&#39;</span><span class="p">]]):</span>
            <span class="nb">print</span><span class="p">(</span>
                <span class="s2">&quot;ERROR: multiple calculation outputs found in file &quot;</span> <span class="o">+</span>
                <span class="n">filename</span> <span class="o">+</span>
                <span class="s2">&quot;. Please instead call QCOutput.mulitple_outputs_from_file(QCOutput,&#39;&quot;</span>
                <span class="o">+</span> <span class="n">filename</span> <span class="o">+</span> <span class="s2">&quot;&#39;)&quot;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Exiting...&quot;</span><span class="p">)</span>
            <span class="n">exit</span><span class="p">()</span>

        <span class="c1"># Parse the molecular details: charge, multiplicity,</span>
        <span class="c1"># species, and initial geometry.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_read_charge_and_multiplicity</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Nuclear Repulsion Energy&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_read_species_and_inital_geometry</span><span class="p">()</span>

        <span class="c1"># Check if calculation finished</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;completion&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;Thank you very much for using Q-Chem.\s+Have a nice day.&quot;</span>
            <span class="p">},</span>
            <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>

        <span class="c1"># If the calculation finished, parse the job time.</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;completion&#39;</span><span class="p">,</span> <span class="p">[]):</span>
            <span class="n">temp_timings</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span>
                        <span class="sa">r</span><span class="s2">&quot;Total job time\:\s*([\d\-\.]+)s\(wall\)\,\s*([\d\-\.]+)s\(cpu\)&quot;</span>
                <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">temp_timings</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;walltime&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_timings</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;cputime&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_timings</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;walltime&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;cputime&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="c1"># Check if calculation is unrestricted</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;unrestricted&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;A(?:n)*\sunrestricted[\s\w\-]+SCF\scalculation\swill\sbe&quot;</span>
            <span class="p">},</span>
            <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>

        <span class="c1"># Check if calculation uses GEN_SCFMAN, multiple potential output formats</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;using_GEN_SCFMAN&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\s+GEN_SCFMAN: A general SCF calculation manager&quot;</span>
            <span class="p">},</span>
            <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;using_GEN_SCFMAN&quot;</span><span class="p">]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;using_GEN_SCFMAN&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\s+General SCF calculation program by&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>

        <span class="c1"># Check if the SCF failed to converge</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;SCF failed to converge&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;SCF_failed_to_converge&quot;</span><span class="p">]</span>

        <span class="c1"># Parse the SCF</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_read_SCF</span><span class="p">()</span>

        <span class="c1"># Parse the Mulliken/ESP/RESP charges</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_read_charges</span><span class="p">()</span>

        <span class="c1"># Check for various warnings</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_detect_general_warnings</span><span class="p">()</span>

        <span class="c1"># Check to see if PCM or SMD are present</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_method&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;solvent_method\s*=?\s*pcm&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_method&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;PCM&quot;</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;solvent_method\s*=?\s*smd&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_method&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;SMD&quot;</span>

        <span class="c1"># Parse information specific to a solvent model</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_method&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;PCM&quot;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="n">temp_dielectric</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;dielectric\s*([\d\-\.]+)&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">][</span><span class="s2">&quot;PCM_dielectric&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_dielectric</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_read_pcm_information</span><span class="p">()</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_method&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;SMD&quot;</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                        <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Unrecognized solvent&quot;</span>
                    <span class="p">},</span>
                    <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;completion&#39;</span><span class="p">,</span> <span class="p">[]):</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;unrecognized_solvent&quot;</span><span class="p">]</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;unrecognized_solvent&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="n">temp_solvent</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\s[Ss]olvent:? ([a-zA-Z]+)&quot;</span>
                <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">temp_solvent</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">val</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="n">temp_solvent</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>
                    <span class="k">if</span> <span class="n">val</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">&quot;for&quot;</span><span class="p">:</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;SMD_two_solvents&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">temp_solvent</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot; and &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">val</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="k">if</span> <span class="s2">&quot;unrecognized_solvent&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="ow">and</span> <span class="s2">&quot;unrecognized_solvent&quot;</span> <span class="ow">not</span> <span class="ow">in</span> \
                                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">]:</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;questionable_SMD_parsing&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">][</span><span class="s2">&quot;SMD_solvent&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">temp_solvent</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_read_smd_information</span><span class="p">()</span>

        <span class="c1"># Parse the final energy</span>
        <span class="n">temp_final_energy</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Final\senergy\sis\s+([\d\-\.]+)&quot;</span>
            <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">temp_final_energy</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;final_energy&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;final_energy&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_final_energy</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>

        <span class="c1"># Check if calculation is using dft_d and parse relevant info if so</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;using_dft_d3&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;dft_d\s*= d3&quot;</span>
            <span class="p">},</span>
            <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;using_dft_d3&#39;</span><span class="p">,</span> <span class="p">[]):</span>
            <span class="n">temp_d3</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\-D3 energy without 3body term =\s*([\d\.\-]+) hartrees&quot;</span>
            <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
            <span class="n">real_d3</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_d3</span><span class="p">))</span>
            <span class="k">if</span> <span class="n">temp_d3</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;dft_d3&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">temp_d3</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;dft_d3&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_d3</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_d3</span><span class="p">):</span>
                    <span class="n">real_d3</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;dft_d3&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">real_d3</span>

        <span class="c1"># Parse the S2 values in the case of an unrestricted calculation</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;unrestricted&#39;</span><span class="p">,</span> <span class="p">[]):</span>
            <span class="n">correct_s2</span> <span class="o">=</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;multiplicity&quot;</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mf">0.5</span> <span class="o">*</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;multiplicity&quot;</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
            <span class="n">temp_S2</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;&lt;S\^2&gt;\s=\s+([\d\-\.]+)&quot;</span>
            <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">temp_S2</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;S2&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">temp_S2</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;S2&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_S2</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
                <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="n">correct_s2</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;S2&quot;</span><span class="p">])</span> <span class="o">&gt;</span> <span class="mf">0.01</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;spin_contamination&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">abs</span><span class="p">(</span><span class="n">correct_s2</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;S2&quot;</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">real_S2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_S2</span><span class="p">))</span>
                <span class="n">have_spin_contamination</span> <span class="o">=</span> <span class="kc">False</span>
                <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_S2</span><span class="p">):</span>
                    <span class="n">real_S2</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                    <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="n">correct_s2</span> <span class="o">-</span> <span class="n">real_S2</span><span class="p">[</span><span class="n">ii</span><span class="p">])</span> <span class="o">&gt;</span> <span class="mf">0.01</span><span class="p">:</span>
                        <span class="n">have_spin_contamination</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;S2&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">real_S2</span>
                <span class="k">if</span> <span class="n">have_spin_contamination</span><span class="p">:</span>
                    <span class="n">spin_contamination</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;S2&quot;</span><span class="p">]))</span>
                    <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;S2&quot;</span><span class="p">]):</span>
                        <span class="n">spin_contamination</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">abs</span><span class="p">(</span><span class="n">correct_s2</span> <span class="o">-</span> <span class="n">entry</span><span class="p">)</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;spin_contamination&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">spin_contamination</span>

        <span class="c1"># Check if the calculation is a geometry optimization. If so, parse the relevant output</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;optimization&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;(?i)\s*job(?:_)*type\s*(?:=)*\s*opt&quot;</span>
            <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;optimization&#39;</span><span class="p">,</span> <span class="p">[]):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_read_optimization_data</span><span class="p">()</span>

        <span class="c1"># Check if the calculation contains a constraint in an $opt section.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;opt_constraint&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
            <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\$opt\s+CONSTRAINT&quot;</span>
        <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;opt_constraint&#39;</span><span class="p">):</span>
            <span class="n">temp_constraint</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Constraints and their Current Values\s+Value\s+Constraint\s+(\w+)\:\s+([\d\-\.]+)\s+&quot;</span>
                           <span class="sa">r</span><span class="s2">&quot;([\d\-\.]+)\s+([\d\-\.]+)\s+([\d\-\.]+)\s+([\d\-\.]+)\s+([\d\-\.]+)&quot;</span>
                <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">temp_constraint</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;opt_constraint&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">temp_constraint</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">if</span> <span class="nb">float</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;opt_constraint&#39;</span><span class="p">)[</span><span class="mi">5</span><span class="p">])</span> <span class="o">!=</span> <span class="nb">float</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;opt_constraint&#39;</span><span class="p">)[</span><span class="mi">6</span><span class="p">]):</span>
                    <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;opt_constraint&#39;</span><span class="p">)[</span><span class="mi">5</span><span class="p">]))</span> <span class="o">!=</span> <span class="nb">abs</span><span class="p">(</span>
                            <span class="nb">float</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;opt_constraint&#39;</span><span class="p">)[</span><span class="mi">6</span><span class="p">])):</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                            <span class="s2">&quot;ERROR: Opt section value and constraint should be the same!&quot;</span>
                        <span class="p">)</span>
                    <span class="k">elif</span> <span class="nb">abs</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;opt_constraint&#39;</span><span class="p">)[</span><span class="mi">5</span><span class="p">]))</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span>
                        <span class="mf">0.0</span><span class="p">,</span> <span class="mf">180.0</span>
                    <span class="p">]:</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                            <span class="s2">&quot;ERROR: Opt section value and constraint can only differ by a sign at 0.0 and 180.0!&quot;</span>
                        <span class="p">)</span>

        <span class="c1"># Check if the calculation is a frequency analysis. If so, parse the relevant output</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;frequency_job&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;(?i)\s*job(?:_)*type\s*(?:=)*\s*freq&quot;</span>
            <span class="p">},</span>
            <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;frequency_job&#39;</span><span class="p">,</span> <span class="p">[]):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_read_frequency_data</span><span class="p">()</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;single_point_job&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;(?i)\s*job(?:_)*type\s*(?:=)*\s*sp&quot;</span>
            <span class="p">},</span>
            <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;key&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;single_point_job&quot;</span><span class="p">,</span> <span class="p">[]):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_read_single_point_data</span><span class="p">()</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;force_job&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;(?i)\s*job(?:_)*type\s*(?:=)*\s*force&quot;</span>
            <span class="p">},</span>
            <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;key&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;force&quot;</span><span class="p">,</span> <span class="p">[]):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_read_force_data</span><span class="p">()</span>

        <span class="c1"># If the calculation did not finish and no errors have been identified yet, check for other errors</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;completion&#39;</span><span class="p">,</span>
                             <span class="p">[])</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;errors&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_check_completion_errors</span><span class="p">()</span>

<div class="viewcode-block" id="QCOutput.multiple_outputs_from_file"><a class="viewcode-back" href="../../../../pymatgen.io.qchem.outputs.html#pymatgen.io.qchem.outputs.QCOutput.multiple_outputs_from_file">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">multiple_outputs_from_file</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">keep_sub_files</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses a QChem output file with multiple calculations</span>
<span class="sd">        1.) Seperates the output into sub-files</span>
<span class="sd">            e.g. qcout -&gt; qcout.0, qcout.1, qcout.2 ... qcout.N</span>
<span class="sd">            a.) Find delimeter for multiple calcualtions</span>
<span class="sd">            b.) Make seperate output sub-files</span>
<span class="sd">        2.) Creates seperate QCCalcs for each one from the sub-files</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">to_return</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">text</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;\s*(?:Running\s+)*Job\s+\d+\s+of\s+\d+\s+&#39;</span><span class="p">,</span>
                            <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
        <span class="k">if</span> <span class="n">text</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;&#39;</span><span class="p">:</span>
            <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">sub_text</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">text</span><span class="p">):</span>
            <span class="n">temp</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
            <span class="n">temp</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">sub_text</span><span class="p">)</span>
            <span class="n">temp</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
            <span class="n">tempOutput</span> <span class="o">=</span> <span class="bp">cls</span><span class="p">(</span><span class="n">filename</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
            <span class="n">to_return</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tempOutput</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">keep_sub_files</span><span class="p">:</span>
                <span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">filename</span> <span class="o">+</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
        <span class="k">return</span> <span class="n">to_return</span></div>

    <span class="k">def</span> <span class="nf">_read_charge_and_multiplicity</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses charge and multiplicity.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">temp_charge</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\$molecule\s+([\-\d]+)\s+\d&quot;</span>
            <span class="p">},</span>
            <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">temp_charge</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;charge&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">temp_charge</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">temp_charge</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Sum of atomic charges \=\s+([\d\-\.\+]+)&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">temp_charge</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;charge&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;charge&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">temp_charge</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]))</span>

        <span class="n">temp_multiplicity</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\$molecule\s+[\-\d]+\s+(\d)&quot;</span>
            <span class="p">},</span>
            <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">temp_multiplicity</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;multiplicity&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">temp_multiplicity</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">temp_multiplicity</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Sum of spin\s+charges \=\s+([\d\-\.\+]+)&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">temp_multiplicity</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;multiplicity&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;multiplicity&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span>
                    <span class="nb">float</span><span class="p">(</span><span class="n">temp_multiplicity</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]))</span> <span class="o">+</span> <span class="mi">1</span>

    <span class="k">def</span> <span class="nf">_read_species_and_inital_geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses species and initial geometry.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;Standard Nuclear Orientation \(Angstroms\)\s+I\s+Atom\s+X\s+Y\s+Z\s+-+&quot;</span>
        <span class="n">table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s*\d+\s+([a-zA-Z]+)\s*([\d\-\.]+)\s*([\d\-\.]+)\s*([\d\-\.]+)\s*&quot;</span>
        <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s*-+&quot;</span>
        <span class="n">temp_geom</span> <span class="o">=</span> <span class="n">read_table_pattern</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">header_pattern</span><span class="p">,</span>
                                       <span class="n">table_pattern</span><span class="p">,</span> <span class="n">footer_pattern</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">temp_geom</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">temp_geom</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;species&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;initial_geometry&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;initial_molecule&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;point_group&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">temp_point_group</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span>
                        <span class="sa">r</span><span class="s2">&quot;Molecular Point Group\s+([A-Za-z\d\*]+)&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">temp_point_group</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;point_group&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">temp_point_group</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;point_group&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="n">temp_geom</span> <span class="o">=</span> <span class="n">temp_geom</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">species</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">geometry</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_geom</span><span class="p">),</span> <span class="mi">3</span><span class="p">),</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">float</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_geom</span><span class="p">):</span>
                <span class="n">species</span> <span class="o">+=</span> <span class="p">[</span><span class="n">entry</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
                <span class="k">for</span> <span class="n">jj</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                    <span class="n">geometry</span><span class="p">[</span><span class="n">ii</span><span class="p">,</span> <span class="n">jj</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="n">jj</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;species&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">species</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;initial_geometry&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">geometry</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;charge&quot;</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;multiplicity&quot;</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;initial_molecule&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Molecule</span><span class="p">(</span>
                    <span class="n">species</span><span class="o">=</span><span class="n">species</span><span class="p">,</span>
                    <span class="n">coords</span><span class="o">=</span><span class="n">geometry</span><span class="p">,</span>
                    <span class="n">charge</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;charge&#39;</span><span class="p">),</span>
                    <span class="n">spin_multiplicity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;multiplicity&#39;</span><span class="p">))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;initial_molecule&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>

    <span class="k">def</span> <span class="nf">_read_SCF</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses both old and new SCFs.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;using_GEN_SCFMAN&#39;</span><span class="p">,</span> <span class="p">[]):</span>
            <span class="k">if</span> <span class="s2">&quot;SCF_failed_to_converge&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;errors&quot;</span><span class="p">):</span>
                <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;^\s*gen_scfman_exception: SCF failed to converge&quot;</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;^\s*\-+\n\s+SCF time&quot;</span>
            <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;^\s*\-+\s+Cycle\s+Energy\s+(?:(?:DIIS)*\s+[Ee]rror)*(?:RMS Gradient)*\s+\-+&quot;</span> \
                             <span class="sa">r</span><span class="s2">&quot;(?:\s*\-+\s+OpenMP\s+Integral\s+computing\s+Module\s+&quot;</span> \
                             <span class="sa">r</span><span class="s2">&quot;(?:Release:\s+version\s+[\d\-\.]+\,\s+\w+\s+[\d\-\.]+\, &quot;</span> \
                             <span class="sa">r</span><span class="s2">&quot;Q-Chem Inc\. Pittsburgh\s+)*\-+)*\n&quot;</span>
            <span class="n">table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;(?:\n[a-zA-Z_\s/]+\.C::(?:WARNING energy changes are now smaller than effective &quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;accuracy\.)*(?:\s+calculation will continue, but THRESH should be increased)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\s+or SCF_CONVERGENCE decreased\. )*(?:\s+effective_thresh = [\d\-\.]+e[\d\-]+)*)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\s*Nonlocal correlation = [\d\-\.]+e[\d\-]+)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\s*Inaccurate integrated density:\n\s+Number of electrons\s+=\s+[\d\-\.]+\n\s+&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;Numerical integral\s+=\s+[\d\-\.]+\n\s+Relative error\s+=\s+[\d\-\.]+\s+\%\n)*\s*\d+\s+&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;([\d\-\.]+)\s+([\d\-\.]+)e([\d\-\.\+]+)(?:\s+Convergence criterion met)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\s+Preconditoned Steepest Descent)*(?:\s+Roothaan Step)*(?:\s+&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:Normal\s+)*BFGS [Ss]tep)*(?:\s+LineSearch Step)*(?:\s+Line search: overstep)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\s+Dog-leg BFGS step)*(?:\s+Line search: understep)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\s+Descent step)*(?:\s+Done DIIS. Switching to GDM)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\s*\-+\s+Cycle\s+Energy\s+(?:(?:DIIS)*\s+[Ee]rror)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:RMS Gradient)*\s+\-+(?:\s*\-+\s+OpenMP\s+Integral\s+computing\s+Module\s+&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:Release:\s+version\s+[\d\-\.]+\,\s+\w+\s+[\d\-\.]+\, &quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;Q-Chem Inc\. Pittsburgh\s+)*\-+)*\n)*&quot;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="s2">&quot;SCF_failed_to_converge&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;errors&quot;</span><span class="p">):</span>
                <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;^\s*\d+\s*[\d\-\.]+\s+[\d\-\.]+E[\d\-\.]+\s+Convergence\s+failure\n&quot;</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;^\s*\-+\n&quot;</span>
            <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;^\s*\-+\s+Cycle\s+Energy\s+DIIS Error\s+\-+\n&quot;</span>
            <span class="n">table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;(?:\s*Inaccurate integrated density:\n\s+Number of electrons\s+=\s+[\d\-\.]+\n\s+&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;Numerical integral\s+=\s+[\d\-\.]+\n\s+Relative error\s+=\s+[\d\-\.]+\s+\%\n)*\s*\d+\s*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;([\d\-\.]+)\s+([\d\-\.]+)E([\d\-\.\+]+)(?:\s*\n\s*cpu\s+[\d\-\.]+\swall\s+[\d\-\.]+)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\nin dftxc\.C, eleTot sum is:[\d\-\.]+, tauTot is\:[\d\-\.]+)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\s+Convergence criterion met)*(?:\s+Done RCA\. Switching to DIIS)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\n\s*Warning: not using a symmetric Q)*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\nRecomputing EXC\s*[\d\-\.]+\s*[\d\-\.]+\s*[\d\-\.]+&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\s*\nRecomputing EXC\s*[\d\-\.]+\s*[\d\-\.]+\s*[\d\-\.]+)*)*&quot;</span>

        <span class="n">temp_scf</span> <span class="o">=</span> <span class="n">read_table_pattern</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">header_pattern</span><span class="p">,</span> <span class="n">table_pattern</span><span class="p">,</span>
                                      <span class="n">footer_pattern</span><span class="p">)</span>
        <span class="n">real_scf</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">one_scf</span> <span class="ow">in</span> <span class="n">temp_scf</span><span class="p">:</span>
            <span class="n">temp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">one_scf</span><span class="p">),</span> <span class="mi">2</span><span class="p">))</span>
            <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">one_scf</span><span class="p">):</span>
                <span class="n">temp</span><span class="p">[</span><span class="n">ii</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">temp</span><span class="p">[</span><span class="n">ii</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">**</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
            <span class="n">real_scf</span> <span class="o">+=</span> <span class="p">[</span><span class="n">temp</span><span class="p">]</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;SCF&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">real_scf</span>

        <span class="n">temp_thresh_warning</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
            <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\n[a-zA-Z_\s/]+\.C::WARNING energy changes are now smaller than effective accuracy&quot;</span>
                   <span class="sa">r</span><span class="s2">&quot;\.\n[a-zA-Z_\s/]+\.C::\s+calculation will continue, but THRESH should be increased\n&quot;</span>
                   <span class="sa">r</span><span class="s2">&quot;[a-zA-Z_\s/]+\.C::\s+or SCF_CONVERGENCE decreased\. \n&quot;</span>
                   <span class="sa">r</span><span class="s2">&quot;[a-zA-Z_\s/]+\.C::\s+effective_thresh = ([\d\-\.]+e[\d\-]+)&quot;</span>
        <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">temp_thresh_warning</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">temp_thresh_warning</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;thresh&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_thresh_warning</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">thresh_warning</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_thresh_warning</span><span class="p">))</span>
                <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_thresh_warning</span><span class="p">):</span>
                    <span class="n">thresh_warning</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;thresh&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">thresh_warning</span>

        <span class="n">temp_SCF_energy</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
            <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;SCF   energy in the final basis set =\s*([\d\-\.]+)&quot;</span>
        <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">temp_SCF_energy</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">temp_SCF_energy</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;SCF_energy_in_the_final_basis_set&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_SCF_energy</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">SCF_energy</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_SCF_energy</span><span class="p">))</span>
                <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_SCF_energy</span><span class="p">):</span>
                    <span class="n">SCF_energy</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">val</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;SCF_energy_in_the_final_basis_set&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">SCF_energy</span>

        <span class="n">temp_Total_energy</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
            <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Total energy in the final basis set =\s*([\d\-\.]+)&quot;</span>
        <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">temp_Total_energy</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">temp_Total_energy</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;Total_energy_in_the_final_basis_set&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_Total_energy</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">Total_energy</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_Total_energy</span><span class="p">))</span>
                <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_Total_energy</span><span class="p">):</span>
                    <span class="n">Total_energy</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">val</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;Total_energy_in_the_final_basis_set&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Total_energy</span>

    <span class="k">def</span> <span class="nf">_read_charges</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses Mulliken/ESP/RESP charges. Also parses spins given an unrestricted SCF.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;unrestricted&#39;</span><span class="p">,</span> <span class="p">[]):</span>
            <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\-+\s+Ground-State Mulliken Net Atomic Charges\s+Atom\s+Charge \(a\.u\.\)\s+&quot;</span> \
                             <span class="sa">r</span><span class="s2">&quot;Spin\s\(a\.u\.\)\s+\-+&quot;</span>
            <span class="n">table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s+\d+\s\w+\s+([\d\-\.]+)\s+([\d\-\.]+)&quot;</span>
            <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s\s\-+\s+Sum of atomic charges&quot;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\-+\s+Ground-State Mulliken Net Atomic Charges\s+Atom\s+Charge \(a\.u\.\)\s+\-+&quot;</span>
            <span class="n">table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s+\d+\s\w+\s+([\d\-\.]+)&quot;</span>
            <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s\s\-+\s+Sum of atomic charges&quot;</span>

        <span class="n">temp_mulliken</span> <span class="o">=</span> <span class="n">read_table_pattern</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">header_pattern</span><span class="p">,</span>
                                           <span class="n">table_pattern</span><span class="p">,</span> <span class="n">footer_pattern</span><span class="p">)</span>
        <span class="n">real_mulliken</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">one_mulliken</span> <span class="ow">in</span> <span class="n">temp_mulliken</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;unrestricted&#39;</span><span class="p">,</span> <span class="p">[]):</span>
                <span class="n">temp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">one_mulliken</span><span class="p">),</span> <span class="mi">2</span><span class="p">))</span>
                <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">one_mulliken</span><span class="p">):</span>
                    <span class="n">temp</span><span class="p">[</span><span class="n">ii</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                    <span class="n">temp</span><span class="p">[</span><span class="n">ii</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">temp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">one_mulliken</span><span class="p">))</span>
                <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">one_mulliken</span><span class="p">):</span>
                    <span class="n">temp</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="n">real_mulliken</span> <span class="o">+=</span> <span class="p">[</span><span class="n">temp</span><span class="p">]</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;Mulliken&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">real_mulliken</span>

        <span class="c1"># Check for ESP/RESP charges</span>
        <span class="n">esp_or_resp</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Merz-Kollman (R?ESP) Net Atomic Charges&quot;</span>
            <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">esp_or_resp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;Merz-Kollman (R?ESP) Net Atomic Charges\s+Atom\s+Charge \(a\.u\.\)\s+\-+&quot;</span>
            <span class="n">table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s+\d+\s\w+\s+([\d\-\.]+)&quot;</span>
            <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s\s\-+\s+Sum of atomic charges&quot;</span>

            <span class="n">temp_esp_or_resp</span> <span class="o">=</span> <span class="n">read_table_pattern</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">header_pattern</span><span class="p">,</span>
                                                  <span class="n">table_pattern</span><span class="p">,</span> <span class="n">footer_pattern</span><span class="p">)</span>
            <span class="n">real_esp_or_resp</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">one_entry</span> <span class="ow">in</span> <span class="n">temp_esp_or_resp</span><span class="p">:</span>
                <span class="n">temp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">one_entry</span><span class="p">))</span>
                <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">one_entry</span><span class="p">):</span>
                    <span class="n">temp</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">real_esp_or_resp</span> <span class="o">+=</span> <span class="p">[</span><span class="n">temp</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="n">esp_or_resp</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">real_esp_or_resp</span>

    <span class="k">def</span> <span class="nf">_detect_general_warnings</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="c1"># Check for inaccurate integrated density</span>
        <span class="n">temp_inac_integ</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Inaccurate integrated density:\n\s+Number of electrons\s+=\s+([\d\-\.]+)\n\s+&quot;</span>
                       <span class="sa">r</span><span class="s2">&quot;Numerical integral\s+=\s+([\d\-\.]+)\n\s+Relative error\s+=\s+([\d\-\.]+)\s+\%\n&quot;</span>
            <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">temp_inac_integ</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">inaccurate_integrated_density</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_inac_integ</span><span class="p">),</span> <span class="mi">3</span><span class="p">))</span>
            <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_inac_integ</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">jj</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">entry</span><span class="p">):</span>
                    <span class="n">inaccurate_integrated_density</span><span class="p">[</span><span class="n">ii</span><span class="p">][</span><span class="n">jj</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">val</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;inaccurate_integrated_density&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">inaccurate_integrated_density</span>

        <span class="c1"># Check for an MKL error</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Intel MKL ERROR&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;mkl&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Check if the job is being hindered by a lack of analytical derivatives</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Starting finite difference calculation for IDERIV&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;missing_analytical_derivates&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Check if the job is complaining about MO files of inconsistent size</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Inconsistent size for SCF MO coefficient file&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;inconsistent_size&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Check for AO linear depend</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Linear dependence detected in AO basis&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;linear_dependence&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Check for Hessian without desired local structure</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\*\*WARNING\*\* Hessian does not have the Desired Local Structure&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;hessian_local_structure&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Check if GetCART cycle iterations ever exceeded</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\*\*\*ERROR\*\*\* Exceeded allowed number of iterative cycles in GetCART&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;GetCART_cycles&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Check for problems with internal coordinates</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\*\*WARNING\*\* Problems with Internal Coordinates&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;internal_coordinates&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Check for problem with eigenvalue magnitude</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\*\*WARNING\*\* Magnitude of eigenvalue&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;eigenvalue_magnitude&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Check for problem with hereditary postivive definiteness</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\*\*WARNING\*\* Hereditary positive definiteness endangered&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;positive_definiteness_endangered&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Check if there were problems with a colinear bend</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\*\*\*ERROR\*\*\* Angle[\s\d]+is near\-linear\s+&quot;</span>
                           <span class="sa">r</span><span class="s2">&quot;But No atom available to define colinear bend&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;colinear_bend&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Check if there were problems diagonalizing B*B(t)</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\*\*\*ERROR\*\*\* Unable to Diagonalize B\*B\(t\) in &lt;MakeNIC&gt;&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;diagonalizing_BBt&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Check for bad Roothaan step</span>
        <span class="k">for</span> <span class="n">scf</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;SCF&quot;</span><span class="p">]:</span>
            <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="n">scf</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">scf</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span> <span class="o">&gt;</span> <span class="mf">10.0</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;bad_roothaan&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

    <span class="k">def</span> <span class="nf">_read_geometries</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses all geometries from an optimization trajectory.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">geoms</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s+Optimization\sCycle:\s+\d+\s+Coordinates \(Angstroms\)\s+ATOM\s+X\s+Y\s+Z&quot;</span>
        <span class="n">table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s+\d+\s+\w+\s+([\d\-\.]+)\s+([\d\-\.]+)\s+([\d\-\.]+)&quot;</span>
        <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s+Point Group\:\s+[\d\w\*]+\s+Number of degrees of freedom\:\s+\d+&quot;</span>

        <span class="n">parsed_geometries</span> <span class="o">=</span> <span class="n">read_table_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">header_pattern</span><span class="p">,</span> <span class="n">table_pattern</span><span class="p">,</span> <span class="n">footer_pattern</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">parsed_geometry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">parsed_geometries</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">parsed_geometry</span> <span class="o">==</span> <span class="p">[]</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">geoms</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">geoms</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">process_parsed_coords</span><span class="p">(</span><span class="n">parsed_geometry</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;geometries&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">geoms</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;last_geometry&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">geoms</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;charge&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;molecule_from_last_geometry&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Molecule</span><span class="p">(</span>
                <span class="n">species</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;species&#39;</span><span class="p">),</span>
                <span class="n">coords</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;last_geometry&#39;</span><span class="p">),</span>
                <span class="n">charge</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;charge&#39;</span><span class="p">),</span>
                <span class="n">spin_multiplicity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;multiplicity&#39;</span><span class="p">))</span>

        <span class="c1"># Parses optimized XYZ coordinates. If not present, parses optimized Z-matrix.</span>
        <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\*+\s+OPTIMIZATION\s+CONVERGED\s+\*+\s+\*+\s+Coordinates \(Angstroms\)\s+ATOM\s+X\s+Y\s+Z&quot;</span>
        <span class="n">table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s+\d+\s+\w+\s+([\d\-\.]+)\s+([\d\-\.]+)\s+([\d\-\.]+)&quot;</span>
        <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s+Z-matrix Print:&quot;</span>

        <span class="n">parsed_optimized_geometry</span> <span class="o">=</span> <span class="n">read_table_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">header_pattern</span><span class="p">,</span> <span class="n">table_pattern</span><span class="p">,</span> <span class="n">footer_pattern</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">parsed_optimized_geometry</span> <span class="o">==</span> <span class="p">[]</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;optimized_geometry&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;^\s+\*+\s+OPTIMIZATION CONVERGED\s+\*+\s+\*+\s+Z-matrix\s+&quot;</span> \
                             <span class="sa">r</span><span class="s2">&quot;Print:\s+\$molecule\s+[\d\-]+\s+[\d\-]+\n&quot;</span>
            <span class="n">table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s*(\w+)(?:\s+(\d+)\s+([\d\-\.]+)(?:\s+(\d+)\s+([\d\-\.]+)&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;(?:\s+(\d+)\s+([\d\-\.]+))*)*)*(?:\s+0)*&quot;</span>
            <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;^\$end\n&quot;</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;optimized_zmat&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_table_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">header_pattern</span><span class="p">,</span> <span class="n">table_pattern</span><span class="p">,</span> <span class="n">footer_pattern</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;optimized_geometry&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">process_parsed_coords</span><span class="p">(</span>
                <span class="n">parsed_optimized_geometry</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;charge&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;molecule_from_optimized_geometry&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Molecule</span><span class="p">(</span>
                    <span class="n">species</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;species&#39;</span><span class="p">),</span>
                    <span class="n">coords</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;optimized_geometry&#39;</span><span class="p">),</span>
                    <span class="n">charge</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;charge&#39;</span><span class="p">),</span>
                    <span class="n">spin_multiplicity</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;multiplicity&#39;</span><span class="p">))</span>

    <span class="k">def</span> <span class="nf">_get_grad_format_length</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">header</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Determines the maximum number of gradient entries printed on a line,</span>
<span class="sd">        which changes for different versions of Q-Chem</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">found_end</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">index</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="n">pattern</span> <span class="o">=</span> <span class="n">header</span>
        <span class="k">while</span> <span class="ow">not</span> <span class="n">found_end</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                        <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="n">pattern</span>
                    <span class="p">},</span>
                    <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">!=</span> <span class="p">[[]]:</span>
                <span class="n">found_end</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">pattern</span> <span class="o">=</span> <span class="n">pattern</span> <span class="o">+</span> <span class="sa">r</span><span class="s2">&quot;\s+&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">index</span><span class="p">)</span>
                <span class="n">index</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="k">return</span> <span class="n">index</span> <span class="o">-</span> <span class="mi">2</span>

    <span class="k">def</span> <span class="nf">_read_gradients</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses all gradients obtained during an optimization trajectory</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">grad_header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;Gradient of (?:SCF)?(?:MP2)? Energy(?: \(in au\.\))?&quot;</span>
        <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;(?:Max gradient component|Gradient time)&quot;</span>

        <span class="n">grad_format_length</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_grad_format_length</span><span class="p">(</span><span class="n">grad_header_pattern</span><span class="p">)</span>
        <span class="n">grad_table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;(?:\s+\d+(?:\s+\d+)?(?:\s+\d+)?(?:\s+\d+)?(?:\s+\d+)?(?:\s+\d+)?)?\n\s\s\s\s[1-3]\s*&quot;</span> \
                             <span class="sa">r</span><span class="s2">&quot;(\-?[\d\.]{9,12})&quot;</span>
        <span class="k">if</span> <span class="n">grad_format_length</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">ii</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">grad_format_length</span><span class="p">):</span>
                <span class="n">grad_table_pattern</span> <span class="o">=</span> <span class="n">grad_table_pattern</span> <span class="o">+</span> <span class="sa">r</span><span class="s2">&quot;(?:\s*(\-?[\d\.]{9,12}))?&quot;</span>

        <span class="n">parsed_gradients</span> <span class="o">=</span> <span class="n">read_table_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">grad_header_pattern</span><span class="p">,</span> <span class="n">grad_table_pattern</span><span class="p">,</span> <span class="n">footer_pattern</span><span class="p">)</span>
        <span class="n">sorted_gradients</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">parsed_gradients</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;initial_molecule&quot;</span><span class="p">]),</span> <span class="mi">3</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">grad</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">parsed_gradients</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">jj</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">grad</span><span class="p">)</span> <span class="o">/</span> <span class="mi">3</span><span class="p">)):</span>
                <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">grad_format_length</span><span class="p">):</span>
                    <span class="k">if</span> <span class="n">grad</span><span class="p">[</span><span class="n">jj</span> <span class="o">*</span> <span class="mi">3</span><span class="p">][</span><span class="n">kk</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;None&#39;</span><span class="p">:</span>
                        <span class="n">sorted_gradients</span><span class="p">[</span><span class="n">ii</span><span class="p">][</span><span class="n">jj</span> <span class="o">*</span> <span class="n">grad_format_length</span> <span class="o">+</span> <span class="n">kk</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">grad</span><span class="p">[</span><span class="n">jj</span> <span class="o">*</span> <span class="mi">3</span><span class="p">][</span><span class="n">kk</span><span class="p">]</span>
                        <span class="n">sorted_gradients</span><span class="p">[</span><span class="n">ii</span><span class="p">][</span><span class="n">jj</span> <span class="o">*</span> <span class="n">grad_format_length</span> <span class="o">+</span> <span class="n">kk</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">grad</span><span class="p">[</span><span class="n">jj</span> <span class="o">*</span> <span class="mi">3</span> <span class="o">+</span> <span class="mi">1</span><span class="p">][</span><span class="n">kk</span><span class="p">]</span>
                        <span class="n">sorted_gradients</span><span class="p">[</span><span class="n">ii</span><span class="p">][</span><span class="n">jj</span> <span class="o">*</span> <span class="n">grad_format_length</span> <span class="o">+</span> <span class="n">kk</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">grad</span><span class="p">[</span><span class="n">jj</span> <span class="o">*</span> <span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="p">][</span><span class="n">kk</span><span class="p">]</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;gradients&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">sorted_gradients</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_method&quot;</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;total gradient after adding PCM contribution --\s+-+\s+Atom\s+X\s+Y\s+Z\s+-+&quot;</span>
            <span class="n">table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s+\d+\s+([\d\-\.]+)\s+([\d\-\.]+)\s+([\d\-\.]+)\s&quot;</span>
            <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;-+&quot;</span>

            <span class="n">parsed_gradients</span> <span class="o">=</span> <span class="n">read_table_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">header_pattern</span><span class="p">,</span> <span class="n">table_pattern</span><span class="p">,</span> <span class="n">footer_pattern</span><span class="p">)</span>

            <span class="n">pcm_gradients</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">parsed_gradients</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;initial_molecule&quot;</span><span class="p">]),</span> <span class="mi">3</span><span class="p">))</span>
            <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">grad</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">parsed_gradients</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">jj</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">grad</span><span class="p">):</span>
                    <span class="k">for</span> <span class="n">kk</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">entry</span><span class="p">):</span>
                        <span class="n">pcm_gradients</span><span class="p">[</span><span class="n">ii</span><span class="p">][</span><span class="n">jj</span><span class="p">][</span><span class="n">kk</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">val</span><span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;pcm_gradients&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pcm_gradients</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;pcm_gradients&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
            <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Gradient of CDS energy&quot;</span>
        <span class="p">},</span>
                        <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;Gradient of CDS energy&quot;</span>

            <span class="n">parsed_gradients</span> <span class="o">=</span> <span class="n">read_table_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">header_pattern</span><span class="p">,</span> <span class="n">grad_table_pattern</span><span class="p">,</span> <span class="n">grad_header_pattern</span><span class="p">)</span>

            <span class="n">sorted_gradients</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">parsed_gradients</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;initial_molecule&quot;</span><span class="p">]),</span> <span class="mi">3</span><span class="p">))</span>
            <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">grad</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">parsed_gradients</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">jj</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">grad</span><span class="p">)</span> <span class="o">/</span> <span class="mi">3</span><span class="p">)):</span>
                    <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">grad_format_length</span><span class="p">):</span>
                        <span class="k">if</span> <span class="n">grad</span><span class="p">[</span><span class="n">jj</span> <span class="o">*</span> <span class="mi">3</span><span class="p">][</span><span class="n">kk</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;None&#39;</span><span class="p">:</span>
                            <span class="n">sorted_gradients</span><span class="p">[</span><span class="n">ii</span><span class="p">][</span><span class="n">jj</span> <span class="o">*</span> <span class="n">grad_format_length</span> <span class="o">+</span> <span class="n">kk</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">grad</span><span class="p">[</span><span class="n">jj</span> <span class="o">*</span> <span class="mi">3</span><span class="p">][</span><span class="n">kk</span><span class="p">]</span>
                            <span class="n">sorted_gradients</span><span class="p">[</span><span class="n">ii</span><span class="p">][</span><span class="n">jj</span> <span class="o">*</span> <span class="n">grad_format_length</span> <span class="o">+</span> <span class="n">kk</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">grad</span><span class="p">[</span><span class="n">jj</span> <span class="o">*</span> <span class="mi">3</span> <span class="o">+</span> <span class="mi">1</span><span class="p">][</span><span class="n">kk</span><span class="p">]</span>
                            <span class="n">sorted_gradients</span><span class="p">[</span><span class="n">ii</span><span class="p">][</span><span class="n">jj</span> <span class="o">*</span> <span class="n">grad_format_length</span> <span class="o">+</span> <span class="n">kk</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">grad</span><span class="p">[</span><span class="n">jj</span> <span class="o">*</span> <span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="p">][</span><span class="n">kk</span><span class="p">]</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;CDS_gradients&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">sorted_gradients</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;CDS_gradients&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>

    <span class="k">def</span> <span class="nf">_read_optimization_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">temp_energy_trajectory</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\sEnergy\sis\s+([\d\-\.]+)&quot;</span>
            <span class="p">})</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">temp_energy_trajectory</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;energy_trajectory&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">real_energy_trajectory</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_energy_trajectory</span><span class="p">))</span>
            <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_energy_trajectory</span><span class="p">):</span>
                <span class="n">real_energy_trajectory</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;energy_trajectory&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">real_energy_trajectory</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_read_geometries</span><span class="p">()</span>
            <span class="k">if</span> <span class="n">have_babel</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;structure_change&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">check_for_structure_changes</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;initial_molecule&quot;</span><span class="p">],</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;molecule_from_last_geometry&quot;</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_read_gradients</span><span class="p">()</span>
            <span class="c1"># Then, if no optimized geometry or z-matrix is found, and no errors have been previously</span>
            <span class="c1"># idenfied, check to see if the optimization failed to converge or if Lambda wasn&#39;t able</span>
            <span class="c1"># to be determined.</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;errors&quot;</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;optimized_geometry&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">None</span> \
                    <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;optimized_zmat&#39;</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                            <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;MAXIMUM OPTIMIZATION CYCLES REACHED&quot;</span>
                        <span class="p">},</span>
                        <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;out_of_opt_cycles&quot;</span><span class="p">]</span>
                <span class="k">elif</span> <span class="n">read_pattern</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                            <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;UNABLE TO DETERMINE Lamda IN FormD&quot;</span>
                        <span class="p">},</span>
                        <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;unable_to_determine_lamda&quot;</span><span class="p">]</span>

    <span class="k">def</span> <span class="nf">_read_frequency_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses frequencies, enthalpy, entropy, and mode vectors.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">temp_dict</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;frequencies&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*Frequency:\s+(\-?[\d\.\*]+)(?:\s+(\-?[\d\.\*]+)(?:\s+(\-?[\d\.\*]+))*)*&quot;</span><span class="p">,</span>
                <span class="s2">&quot;trans_dip&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;TransDip\s+(\-?[\d\.]{5,7}|\*{5,7})\s*(\-?[\d\.]{5,7}|\*{5,7})\s*(\-?[\d\.]{5,7}|\*{5,7})\s*&quot;</span>
                    <span class="sa">r</span><span class="s2">&quot;(?:(\-?[\d\.]{5,7}|\*{5,7})\s*(\-?[\d\.]{5,7}|\*{5,7})\s*(\-?[\d\.]{5,7}|\*{5,7})\s*&quot;</span>
                    <span class="sa">r</span><span class="s2">&quot;(?:(\-?[\d\.]{5,7}|\*{5,7})\s*(\-?[\d\.]{5,7}|\*{5,7})\s*(\-?[\d\.]{5,7}|\*{5,7}))*)*&quot;</span><span class="p">,</span>
                <span class="s2">&quot;IR_intens&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*IR Intens:\s*(\-?[\d\.\*]+)(?:\s+(\-?[\d\.\*]+)(?:\s+(\-?[\d\.\*]+))*)*&quot;</span><span class="p">,</span>
                <span class="s2">&quot;IR_active&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*IR Active:\s+([YESNO]+)(?:\s+([YESNO]+)(?:\s+([YESNO]+))*)*&quot;</span><span class="p">,</span>
                <span class="s2">&quot;ZPE&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*Zero point vibrational energy:\s+([\d\-\.]+)\s+kcal/mol&quot;</span><span class="p">,</span>
                <span class="s2">&quot;trans_enthalpy&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*Translational Enthalpy:\s+([\d\-\.]+)\s+kcal/mol&quot;</span><span class="p">,</span>
                <span class="s2">&quot;rot_enthalpy&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*Rotational Enthalpy:\s+([\d\-\.]+)\s+kcal/mol&quot;</span><span class="p">,</span>
                <span class="s2">&quot;vib_enthalpy&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*Vibrational Enthalpy:\s+([\d\-\.]+)\s+kcal/mol&quot;</span><span class="p">,</span>
                <span class="s2">&quot;gas_constant&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*gas constant \(RT\):\s+([\d\-\.]+)\s+kcal/mol&quot;</span><span class="p">,</span>
                <span class="s2">&quot;trans_entropy&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*Translational Entropy:\s+([\d\-\.]+)\s+cal/mol\.K&quot;</span><span class="p">,</span>
                <span class="s2">&quot;rot_entropy&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*Rotational Entropy:\s+([\d\-\.]+)\s+cal/mol\.K&quot;</span><span class="p">,</span>
                <span class="s2">&quot;vib_entropy&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*Vibrational Entropy:\s+([\d\-\.]+)\s+cal/mol\.K&quot;</span><span class="p">,</span>
                <span class="s2">&quot;total_enthalpy&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*Total Enthalpy:\s+([\d\-\.]+)\s+kcal/mol&quot;</span><span class="p">,</span>
                <span class="s2">&quot;total_entropy&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*Total Entropy:\s+([\d\-\.]+)\s+cal/mol\.K&quot;</span>
            <span class="p">})</span>

        <span class="n">keys</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;ZPE&quot;</span><span class="p">,</span> <span class="s2">&quot;trans_enthalpy&quot;</span><span class="p">,</span> <span class="s2">&quot;rot_enthalpy&quot;</span><span class="p">,</span> <span class="s2">&quot;vib_enthalpy&quot;</span><span class="p">,</span> <span class="s2">&quot;gas_constant&quot;</span><span class="p">,</span> <span class="s2">&quot;trans_entropy&quot;</span><span class="p">,</span> <span class="s2">&quot;rot_entropy&quot;</span><span class="p">,</span>
                <span class="s2">&quot;vib_entropy&quot;</span><span class="p">,</span> <span class="s2">&quot;total_enthalpy&quot;</span><span class="p">,</span> <span class="s2">&quot;total_entropy&quot;</span><span class="p">]</span>

        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>

        <span class="k">if</span> <span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;frequencies&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;frequencies&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;IR_intens&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;IR_active&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;trans_dip&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">temp_freqs</span> <span class="o">=</span> <span class="p">[</span>
                <span class="n">value</span> <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;frequencies&#39;</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">entry</span>
            <span class="p">]</span>
            <span class="n">temp_intens</span> <span class="o">=</span> <span class="p">[</span>
                <span class="n">value</span> <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;IR_intens&#39;</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">entry</span>
            <span class="p">]</span>
            <span class="n">active</span> <span class="o">=</span> <span class="p">[</span>
                <span class="n">value</span> <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;IR_active&#39;</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">entry</span>
            <span class="p">]</span>
            <span class="n">temp_trans_dip</span> <span class="o">=</span> <span class="p">[</span>
                <span class="n">value</span> <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;trans_dip&#39;</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">entry</span>
            <span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;IR_active&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">active</span>

            <span class="n">trans_dip</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="nb">int</span><span class="p">((</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_trans_dip</span><span class="p">)</span> <span class="o">-</span> <span class="n">temp_trans_dip</span><span class="o">.</span><span class="n">count</span><span class="p">(</span><span class="s1">&#39;None&#39;</span><span class="p">))</span> <span class="o">/</span> <span class="mi">3</span><span class="p">),</span> <span class="mi">3</span><span class="p">))</span>
            <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_trans_dip</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">entry</span> <span class="o">!=</span> <span class="s1">&#39;None&#39;</span><span class="p">:</span>
                    <span class="k">if</span> <span class="s2">&quot;*&quot;</span> <span class="ow">in</span> <span class="n">entry</span><span class="p">:</span>
                        <span class="n">trans_dip</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">ii</span> <span class="o">/</span> <span class="mi">3</span><span class="p">)][</span><span class="n">ii</span> <span class="o">%</span> <span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">trans_dip</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">ii</span> <span class="o">/</span> <span class="mi">3</span><span class="p">)][</span><span class="n">ii</span> <span class="o">%</span> <span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;trans_dip&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">trans_dip</span>

            <span class="n">freqs</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_freqs</span><span class="p">)</span> <span class="o">-</span> <span class="n">temp_freqs</span><span class="o">.</span><span class="n">count</span><span class="p">(</span><span class="s1">&#39;None&#39;</span><span class="p">))</span>
            <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_freqs</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">entry</span> <span class="o">!=</span> <span class="s1">&#39;None&#39;</span><span class="p">:</span>
                    <span class="k">if</span> <span class="s2">&quot;*&quot;</span> <span class="ow">in</span> <span class="n">entry</span><span class="p">:</span>
                        <span class="k">if</span> <span class="n">ii</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                            <span class="n">freqs</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span>
                        <span class="k">elif</span> <span class="n">ii</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">freqs</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span>
                            <span class="n">freqs</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span>
                        <span class="k">elif</span> <span class="n">freqs</span><span class="p">[</span><span class="n">ii</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="o">-</span><span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">):</span>
                            <span class="n">freqs</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span>
                        <span class="k">elif</span> <span class="s2">&quot;*&quot;</span> <span class="ow">in</span> <span class="n">temp_freqs</span><span class="p">[</span><span class="n">ii</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]:</span>
                            <span class="n">freqs</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span>
                                <span class="s2">&quot;ERROR: Encountered an undefined frequency not at the beginning or end of the &quot;</span>
                                <span class="s2">&quot;frequency list, which makes no sense! Exiting...&quot;</span><span class="p">)</span>
                        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;completion&#39;</span><span class="p">,</span> <span class="p">[]):</span>
                            <span class="k">if</span> <span class="s2">&quot;undefined_frequency&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]:</span>
                                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;undefined_frequency&quot;</span><span class="p">]</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="k">if</span> <span class="s2">&quot;undefined_frequency&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">]:</span>
                                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;undefined_frequency&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">freqs</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;frequencies&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">freqs</span>

            <span class="n">intens</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_intens</span><span class="p">)</span> <span class="o">-</span> <span class="n">temp_intens</span><span class="o">.</span><span class="n">count</span><span class="p">(</span><span class="s1">&#39;None&#39;</span><span class="p">))</span>
            <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_intens</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">entry</span> <span class="o">!=</span> <span class="s1">&#39;None&#39;</span><span class="p">:</span>
                    <span class="k">if</span> <span class="s2">&quot;*&quot;</span> <span class="ow">in</span> <span class="n">entry</span><span class="p">:</span>
                        <span class="n">intens</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">intens</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;IR_intens&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">intens</span>

            <span class="n">header_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s*Raman Active:\s+[YESNO]+\s+(?:[YESNO]+\s+)*X\s+Y\s+Z\s+(?:X\s+Y\s+Z\s+)*&quot;</span>
            <span class="n">table_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;\s*[a-zA-Z][a-zA-Z\s]\s*([\d\-\.]+)\s*([\d\-\.]+)\s*([\d\-\.]+)\s*(?:([\d\-\.]+)\s*&quot;</span> \
                            <span class="sa">r</span><span class="s2">&quot;([\d\-\.]+)\s*([\d\-\.]+)\s*(?:([\d\-\.]+)\s*([\d\-\.]+)\s*([\d\-\.]+))*)*&quot;</span>
            <span class="n">footer_pattern</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;TransDip\s+\-?[\d\.\*]+\s*\-?[\d\.\*]+\s*\-?[\d\.\*]+\s*(?:\-?[\d\.\*]+\s*\-?&quot;</span> \
                             <span class="sa">r</span><span class="s2">&quot;[\d\.\*]+\s*\-?[\d\.\*]+\s*)*&quot;</span>
            <span class="n">temp_freq_mode_vecs</span> <span class="o">=</span> <span class="n">read_table_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">header_pattern</span><span class="p">,</span> <span class="n">table_pattern</span><span class="p">,</span> <span class="n">footer_pattern</span><span class="p">)</span>
            <span class="n">freq_mode_vecs</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span>
                <span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">freqs</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="n">temp_freq_mode_vecs</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="mi">3</span><span class="p">))</span>

            <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">triple_FMV</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_freq_mode_vecs</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">jj</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">triple_FMV</span><span class="p">):</span>
                    <span class="k">for</span> <span class="n">kk</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="k">if</span> <span class="n">entry</span> <span class="o">!=</span> <span class="s1">&#39;None&#39;</span><span class="p">:</span>
                            <span class="n">freq_mode_vecs</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">ii</span> <span class="o">*</span> <span class="mi">3</span> <span class="o">+</span> <span class="n">math</span><span class="o">.</span><span class="n">floor</span><span class="p">(</span><span class="n">kk</span> <span class="o">/</span> <span class="mi">3</span><span class="p">)),</span>
                                           <span class="n">jj</span><span class="p">,</span> <span class="n">kk</span> <span class="o">%</span> <span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;frequency_mode_vectors&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">freq_mode_vecs</span>
            <span class="n">freq_length</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;frequencies&quot;</span><span class="p">])</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;frequency_mode_vectors&quot;</span><span class="p">])</span> <span class="o">!=</span> <span class="n">freq_length</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;IR_intens&quot;</span><span class="p">])</span> <span class="o">!=</span> <span class="n">freq_length</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;IR_active&quot;</span><span class="p">])</span> <span class="o">!=</span> <span class="n">freq_length</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;warnings&quot;</span><span class="p">][</span><span class="s2">&quot;frequency_length_inconsistency&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span>

    <span class="k">def</span> <span class="nf">_read_single_point_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses final free energy information from single-point calculations.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">temp_dict</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;final_energy&quot;</span><span class="p">:</span>
                    <span class="sa">r</span><span class="s2">&quot;\s*SCF\s+energy in the final basis set\s+=\s*([\d\-\.]+)&quot;</span>
            <span class="p">})</span>

        <span class="k">if</span> <span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;final_energy&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;final_energy&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># -1 in case of pcm</span>
            <span class="c1"># Two lines will match the above; we want final calculation</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;final_energy&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;final_energy&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>

    <span class="k">def</span> <span class="nf">_read_force_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_read_gradients</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">_read_pcm_information</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses information from PCM solvent calculations.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">temp_dict</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;g_electrostatic&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\s*G_electrostatic\s+=\s+([\d\-\.]+)\s+hartree\s+=\s+([\d\-\.]+)\s+kcal/mol\s*&quot;</span><span class="p">,</span>
                <span class="s2">&quot;g_cavitation&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\s*G_cavitation\s+=\s+([\d\-\.]+)\s+hartree\s+=\s+([\d\-\.]+)\s+kcal/mol\s*&quot;</span><span class="p">,</span>
                <span class="s2">&quot;g_dispersion&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\s*G_dispersion\s+=\s+([\d\-\.]+)\s+hartree\s+=\s+([\d\-\.]+)\s+kcal/mol\s*&quot;</span><span class="p">,</span>
                <span class="s2">&quot;g_repulsion&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\s*G_repulsion\s+=\s+([\d\-\.]+)\s+hartree\s+=\s+([\d\-\.]+)\s+kcal/mol\s*&quot;</span><span class="p">,</span>
                <span class="s2">&quot;total_contribution_pcm&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\s*Total\s+=\s+([\d\-\.]+)\s+hartree\s+=\s+([\d\-\.]+)\s+kcal/mol\s*&quot;</span><span class="p">,</span>
                <span class="s2">&quot;solute_internal_energy&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Solute Internal Energy \(H0\)\s*=\s*([\d\-\.]+)&quot;</span>
            <span class="p">}</span>
        <span class="p">)</span>

        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">temp_dict</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">temp_result</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)))</span>
                <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)):</span>
                    <span class="n">temp_result</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">temp_result</span>

        <span class="n">smd_keys</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;smd0&quot;</span><span class="p">,</span> <span class="s2">&quot;smd3&quot;</span><span class="p">,</span> <span class="s2">&quot;smd4&quot;</span><span class="p">,</span> <span class="s2">&quot;smd6&quot;</span><span class="p">,</span> <span class="s2">&quot;smd9&quot;</span><span class="p">]</span>
        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">smd_keys</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>

    <span class="k">def</span> <span class="nf">_read_smd_information</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses information from SMD solvent calculations.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">temp_dict</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                <span class="s2">&quot;smd0&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;E-EN\(g\) gas\-phase elect\-nuc energy\s*([\d\-\.]+) a\.u\.&quot;</span><span class="p">,</span>
                <span class="s2">&quot;smd3&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;G\-ENP\(liq\) elect\-nuc\-pol free energy of system\s*([\d\-\.]+) a\.u\.&quot;</span><span class="p">,</span>
                <span class="s2">&quot;smd4&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;G\-CDS\(liq\) cavity\-dispersion\-solvent structure\s*free energy\s*([\d\-\.]+) kcal\/mol&quot;</span><span class="p">,</span>
                <span class="s2">&quot;smd6&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;G\-S\(liq\) free energy of system\s*([\d\-\.]+) a\.u\.&quot;</span><span class="p">,</span>
                <span class="s2">&quot;smd9&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;DeltaG\-S\(liq\) free energy of\s*solvation\s*\(9\) = \(6\) \- \(0\)\s*([\d\-\.]+) kcal\/mol&quot;</span>
            <span class="p">}</span>
        <span class="p">)</span>

        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">temp_dict</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">temp_result</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)))</span>
                <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">entry</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">temp_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)):</span>
                    <span class="n">temp_result</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">entry</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">temp_result</span>

        <span class="n">pcm_keys</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;g_electrostatic&quot;</span><span class="p">,</span> <span class="s2">&quot;g_cavitation&quot;</span><span class="p">,</span> <span class="s2">&quot;g_dispersion&quot;</span><span class="p">,</span> <span class="s2">&quot;g_repulsion&quot;</span><span class="p">,</span> <span class="s2">&quot;total_contribution_pcm&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;solute_internal_energy&quot;</span><span class="p">]</span>
        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">pcm_keys</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;solvent_data&quot;</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>

    <span class="k">def</span> <span class="nf">_check_completion_errors</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses potential errors that can cause jobs to crash</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span>
                        <span class="sa">r</span><span class="s2">&quot;Coordinates do not transform within specified threshold&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;failed_to_transform_coords&quot;</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span>
                <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;The Q\-Chem input file has failed to pass inspection&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;input_file_error&quot;</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Error opening input stream&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;failed_to_read_input&quot;</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;FileMan error: End of file reached prematurely&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;premature_end_FileMan_error&quot;</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;method not available&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;method_not_available&quot;</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Could not find \$molecule section in ParseQInput&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;read_molecule_error&quot;</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Welcome to Q-Chem&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">!=</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;never_called_qchem&quot;</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\*\*\*ERROR\*\*\* Hessian Appears to have all zero or negative eigenvalues&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;hessian_eigenvalue_error&quot;</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;FlexNet Licensing error&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;licensing_error&quot;</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;Could not open driver file in ReadDriverFromDisk&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[[]]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;driver_error&quot;</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">tmp_failed_line_searches</span> <span class="o">=</span> <span class="n">read_pattern</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="p">{</span>
                    <span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="sa">r</span><span class="s2">&quot;\d+\s+failed line searches\.\s+Resetting&quot;</span>
                <span class="p">},</span>
                <span class="n">terminate_on_match</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;key&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">tmp_failed_line_searches</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">tmp_failed_line_searches</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">10</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;SCF_failed_to_converge&quot;</span><span class="p">]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;errors&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="p">[]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">&quot;unknown_error&quot;</span><span class="p">]</span>

<div class="viewcode-block" id="QCOutput.as_dict"><a class="viewcode-back" href="../../../../pymatgen.io.qchem.outputs.html#pymatgen.io.qchem.outputs.QCOutput.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns:</span>
<span class="sd">            MSONAble dict.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">d</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;data&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;text&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">text</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;filename&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename</span>
        <span class="k">return</span> <span class="n">jsanitize</span><span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="n">strict</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="check_for_structure_changes"><a class="viewcode-back" href="../../../../pymatgen.io.qchem.outputs.html#pymatgen.io.qchem.outputs.check_for_structure_changes">[docs]</a><span class="k">def</span> <span class="nf">check_for_structure_changes</span><span class="p">(</span><span class="n">mol1</span><span class="p">:</span> <span class="n">Molecule</span><span class="p">,</span> <span class="n">mol2</span><span class="p">:</span> <span class="n">Molecule</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Compares connectivity of two molecules (using MoleculeGraph w/ OpenBabelNN).</span>
<span class="sd">    This function will work with two molecules with different atom orderings,</span>
<span class="sd">        but for proper treatment, atoms should be listed in the same order.</span>
<span class="sd">    Possible outputs include:</span>
<span class="sd">    - no_change: the bonding in the two molecules is identical</span>
<span class="sd">    - unconnected_fragments: the MoleculeGraph of mol1 is connected, but the</span>
<span class="sd">      MoleculeGraph is mol2 is not connected</span>
<span class="sd">    - fewer_bonds: the MoleculeGraph of mol1 has more bonds (edges) than the</span>
<span class="sd">      MoleculeGraph of mol2</span>
<span class="sd">    - more_bonds: the MoleculeGraph of mol2 has more bonds (edges) than the</span>
<span class="sd">      MoleculeGraph of mol1</span>
<span class="sd">    - bond_change: this case catches any other non-identical MoleculeGraphs</span>
<span class="sd">    Args:</span>
<span class="sd">        mol1: Pymatgen Molecule object to be compared.</span>
<span class="sd">        mol2: Pymatgen Molecule object to be compared.</span>
<span class="sd">    Returns:</span>
<span class="sd">        One of [&quot;unconnected_fragments&quot;, &quot;fewer_bonds&quot;, &quot;more_bonds&quot;,</span>
<span class="sd">        &quot;bond_change&quot;, &quot;no_change&quot;]</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">special_elements</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;Li&quot;</span><span class="p">,</span> <span class="s2">&quot;Na&quot;</span><span class="p">,</span> <span class="s2">&quot;Mg&quot;</span><span class="p">,</span> <span class="s2">&quot;Ca&quot;</span><span class="p">,</span> <span class="s2">&quot;Zn&quot;</span><span class="p">]</span>
    <span class="n">mol_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">mol1</span><span class="p">),</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">mol2</span><span class="p">)]</span>

    <span class="k">if</span> <span class="n">mol1</span><span class="o">.</span><span class="n">composition</span> <span class="o">!=</span> <span class="n">mol2</span><span class="o">.</span><span class="n">composition</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">&quot;Molecules have different compositions! Exiting...&quot;</span><span class="p">)</span>

    <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">site</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">mol1</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">symbol</span> <span class="o">!=</span> <span class="n">mol2</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">symbol</span><span class="p">:</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;Comparing molecules with different atom ordering! &quot;</span>
                <span class="s2">&quot;Turning off special treatment for coordinating metals.&quot;</span>
            <span class="p">)</span>
            <span class="n">special_elements</span> <span class="o">=</span> <span class="p">[]</span>

    <span class="n">special_sites</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">]</span> <span class="o">=</span> <span class="p">[[],</span> <span class="p">[]]</span>
    <span class="k">for</span> <span class="n">ii</span><span class="p">,</span> <span class="n">mol</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">mol_list</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">jj</span><span class="p">,</span> <span class="n">site</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">mol</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">symbol</span> <span class="ow">in</span> <span class="n">special_elements</span><span class="p">:</span>
                <span class="n">distances</span> <span class="o">=</span> <span class="p">[[</span><span class="n">kk</span><span class="p">,</span> <span class="n">site</span><span class="o">.</span><span class="n">distance</span><span class="p">(</span><span class="n">other_site</span><span class="p">)]</span>
                             <span class="k">for</span> <span class="n">kk</span><span class="p">,</span> <span class="n">other_site</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">mol</span><span class="p">)]</span>
                <span class="n">special_sites</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">jj</span><span class="p">,</span> <span class="n">site</span><span class="p">,</span> <span class="n">distances</span><span class="p">])</span>
        <span class="k">for</span> <span class="n">jj</span><span class="p">,</span> <span class="n">site</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">mol</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">symbol</span> <span class="ow">in</span> <span class="n">special_elements</span><span class="p">:</span>
                <span class="n">mol</span><span class="o">.</span><span class="fm">__delitem__</span><span class="p">(</span><span class="n">jj</span><span class="p">)</span>

    <span class="c1"># Can add logic to check the distances in the future if desired</span>

    <span class="n">initial_mol_graph</span> <span class="o">=</span> <span class="n">MoleculeGraph</span><span class="o">.</span><span class="n">with_local_env_strategy</span><span class="p">(</span><span class="n">mol_list</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
                                                              <span class="n">OpenBabelNN</span><span class="p">())</span>
    <span class="n">initial_graph</span> <span class="o">=</span> <span class="n">initial_mol_graph</span><span class="o">.</span><span class="n">graph</span>
    <span class="n">last_mol_graph</span> <span class="o">=</span> <span class="n">MoleculeGraph</span><span class="o">.</span><span class="n">with_local_env_strategy</span><span class="p">(</span><span class="n">mol_list</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span>
                                                           <span class="n">OpenBabelNN</span><span class="p">())</span>
    <span class="n">last_graph</span> <span class="o">=</span> <span class="n">last_mol_graph</span><span class="o">.</span><span class="n">graph</span>
    <span class="k">if</span> <span class="n">initial_mol_graph</span><span class="o">.</span><span class="n">isomorphic_to</span><span class="p">(</span><span class="n">last_mol_graph</span><span class="p">):</span>
        <span class="k">return</span> <span class="s2">&quot;no_change&quot;</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">nx</span><span class="o">.</span><span class="n">is_connected</span><span class="p">(</span><span class="n">initial_graph</span><span class="o">.</span><span class="n">to_undirected</span><span class="p">())</span> <span class="ow">and</span>
                <span class="ow">not</span> <span class="n">nx</span><span class="o">.</span><span class="n">is_connected</span><span class="p">(</span><span class="n">last_graph</span><span class="o">.</span><span class="n">to_undirected</span><span class="p">())):</span>
            <span class="k">return</span> <span class="s2">&quot;unconnected_fragments&quot;</span>
        <span class="k">elif</span> <span class="n">last_graph</span><span class="o">.</span><span class="n">number_of_edges</span><span class="p">()</span> <span class="o">&lt;</span> <span class="n">initial_graph</span><span class="o">.</span><span class="n">number_of_edges</span><span class="p">():</span>
            <span class="k">return</span> <span class="s2">&quot;fewer_bonds&quot;</span>
        <span class="k">elif</span> <span class="n">last_graph</span><span class="o">.</span><span class="n">number_of_edges</span><span class="p">()</span> <span class="o">&gt;</span> <span class="n">initial_graph</span><span class="o">.</span><span class="n">number_of_edges</span><span class="p">():</span>
            <span class="k">return</span> <span class="s2">&quot;more_bonds&quot;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="s2">&quot;bond_change&quot;</span></div>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.qchem.outputs</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>